﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace BloxGin.World
{
   public class Sun
    {
        Texture2D texture;
        
        Matrix rotation;
        const float distance = 10000;
        float angles = 0;
        float speed = 1;
        Matrix world;

        public Vector3 position{get;protected set;}

        /// <summary>
        /// Set before LoadContent
        /// </summary>
        public string filename = "sun";

        public void Update(GameTime gameTime,Cameras.ICamera camrea)
        {
            angles += MathHelper.ToRadians((float)gameTime.ElapsedGameTime.TotalSeconds*speed);
           // position.Z++;
            position = new Vector3(0, 100, distance);
            rotation = Matrix.CreateRotationX(angles);
            position = Vector3.Transform(position, rotation);
        }

        public void LoadContent(ContentManager content)
        {
            texture = content.Load<Texture2D>(filename);
        }

        public void Draw(GraphicsDevice device, Matrix view, Matrix projection, SpriteBatch spriteBatch)
        {
            Vector3 a = device.Viewport.Project(position, projection, view, Matrix.Identity);
            Vector2 pos = new Vector2(a.X, a.Y);
            spriteBatch.Begin();
            spriteBatch.Draw(texture, pos, Color.White);
            spriteBatch.End();

            device.DepthStencilState = DepthStencilState.Default;
        }

    }
}
